
export function mappingArray(keyMapping, data) {
  if (!keyMapping || !data) {
    return null
  }
  const result = []
  data.forEach(e => result.push(mapping(keyMapping, e)))
  return result
}

export function mapping(keyMapping, obj) {
  if (!keyMapping || !obj) {
    return null
  }
  const keys = Object.keys(keyMapping)
  const result = {}
  keys.forEach(k => {
    result[keyMapping[k]] = obj[k]
  })
  return result
}

export function mappingPiarArray(keyMappingArray, data) {
  console.log(data)
  if (!keyMappingArray || !data) {
    return null
  }
  const result = []
  data.forEach(e => {
    const obj = {}
    keyMappingArray.forEach(keyMapping => {
      const keys = Object.keys(keyMapping)
      keys.forEach(ky => {
        obj[keyMapping[ky]] = e[ky]
      })
    })
    result.push(obj)
  })
  return result
}
